#include "core/main.h"

void Replay::InitRecording(Game &game, const string &player)
{
    _game = &game;
    _player = player;
    _filename = "notSaved";
    _frames.clear();
}

void Replay::AddFrame(const Frame &f, ControllerState controller)
{
    _frames.push_back(f);

    Frame &newFrame = _frames[_frames.size() - 1];
    newFrame.controller = controller;
}

void Replay::SaveToNewReplayFile()
{
    _filename = "../replays/" + _game->Name() + "/" + _player;

    OutputDataStream s;
    s << _player;
    s << _frames;
    s.SaveToFileNoHeader(_filename);
}

void Replay::Load(Game &game, const string &filename)
{
    _game = &game;
    _filename = filename;
    
    InputDataStream s;
    s.LoadFromFile(filename);
    s >> _player;
    s >> _frames;

    //_frames.resize(10);
}
